package cn.zt.controller;

import cn.zt.common.Result;
import cn.zt.domain.AccountInformation;
import cn.zt.service.AccountInformationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Random;

@RestController
@RequestMapping("accountInformation")
public class AccountInformationController {

    @Resource
    private AccountInformationService accountInformationService;

    @PostMapping("kaihu")
    public Result kaihu(@RequestBody cn.zt.domain.vo.AccountInformationVo accountInformationVo){
        return accountInformationService.kaihu(accountInformationVo);
    }

    //生成一个随机银行卡号
    @GetMapping("yhk")
    public String scyhk(){
        Random random = new Random();
        StringBuilder cardNumber = new StringBuilder("6");
        for (int i = 1; i < 16; i++) {
            cardNumber.append(random.nextInt(10));
        }
        return cardNumber.toString();
    }

    //绑卡
    @PostMapping("bangka")
    public Result bangka(@RequestParam("id") Integer id){
        return accountInformationService.bangka(id);
    }

    //通过银行卡号查询主键
    @GetMapping("selectbybank")
    public Result selectById(@RequestParam("id") String eCard){
        return accountInformationService.selectById(eCard);
    }


}
